package com.paireach.bw.http;

import com.blankj.utilcode.utils.TimeUtils;

import java.util.HashMap;

/**
 * 运单请求
 * <p>
 * , String lng, String lat, String driverNum
 * map.put("lng", lng);
 * map.put("lat", lat);
 * map.put("driverNum", driverNum);
 */
public class WayBillRequest {


    /**
     * 根据手机号码获取登录人的所有运单
     *
     * @param phoneNumber 手机号码
     */
    public void loadAllOrder(String phoneNumber) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loadAllOrder.a", map, RequestTag.GET_ALL_WAY_BILL);
    }

    /**
     * 根据手机号获取第一个可以接的运单
     *
     * @param phoneNumber 手机号
     */
    public void loadFirstAvailableOrder(String phoneNumber) {
        HashMap<String, String> map = new HashMap<>();
        map.put("mobile", phoneNumber);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loadFirstUnCheckOrder.a", map, RequestTag.GET_FIRST_AVAILABLE_WAY_BILL);
    }

    /**
     * 根据运单号获取该运单的详细货物
     *
     * @param orderNo 运单号
     */
    public void getOrderGoodsDetail(String phoneNumber, String orderNo) {
        HashMap<String, String> map = new HashMap<>();
        map.put("userName", phoneNumber);
        map.put("orderCode", orderNo);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loadOrderDetailById.a", map, RequestTag.GET_WAY_BILL_DETAIL_GOODS);
    }

    public void queryOrderJoinList(String phoneNumber, String orderCode) {
        HashMap<String, String> map = new HashMap<>();
        map.put("userName", phoneNumber);
        map.put("orderCode", orderCode);
        String url = NetUrl.zhuang + "queryOrderJoinList.a";
        MainRequest.getInstance().makeStringPostRequest(url, map, RequestTag.QUERY_ORDER_JOIN_LIST);
    }


    /**
     * 弃用 拒绝接受运单
     *
     * @param phoneNumber
     * @param orderNo
     */
    public void driverRefuseOrder(String phoneNumber, String orderNo) {
        HashMap<String, String> map = new HashMap<>();
        map.put("userName", phoneNumber);
        map.put("orderCode", orderNo);
        map.put("isAgree", "0");
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "driverAcceptOrder.a", map, RequestTag.DRIVER_REFUSE_ORDER);
    }


//    @Override
//    public void refuseSign(String phoneNumber, String orderNo, double lat, double lng) {
//        HashMap<String, String> map = new HashMap<>();
//        map.put("userName", phoneNumber);
//        map.put("orderCode", orderNo);
//        map.put("lat", String.valueOf(lat));
//        map.put("lng", String.valueOf(lng));
//        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "orderHandling.a", map, RequestTag.DRIVER_REFUSE_SIGN);
//    }

    /**
     * 确定提货
     *
     * @param phoneNumber
     * @param orderNo
     */
    public void confirmStart(String phoneNumber, String orderNo) {
        HashMap<String, String> map = new HashMap<>();
        map.put("userName", phoneNumber);
        map.put("orderCode", orderNo);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loadEndOrder.a", map, RequestTag.CONFIRM_START);
    }

    /**
     * 确定收货，已废弃
     *
     * @param phoneNumber
     * @param orderNo
     */
    public void confirmEnd(String phoneNumber, String orderNo, double lat, double lng) {
        HashMap<String, String> map = new HashMap<>();
        map.put("userName", phoneNumber);
        map.put("orderCode", orderNo);
        map.put("lat", String.valueOf(lat));
        map.put("lng", String.valueOf(lng));
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "orderHandling.a", map, RequestTag.CONFIRM_END);
    }

    //int alarm_size,   , String action_name
//        map.put("alarm_size", String.valueOf(alarm_size));
//        map.put("action_name", action_name);

    /**
     * 发送地理围栏警报
     */
    public void saveFenceAlarmInfo(String phoneNumber,String monitored_person, int action, long time,
                                   int fence_id, String fence_name, double lng, double lat, int coord_type, int radius,
                                   double pre_lng, double pre_lat, int pre_coord_type, long pre_time, int pre_radius) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("monitored_person", monitored_person);
        map.put("action", String.valueOf(action));
        map.put("time", TimeUtils.millis2String(time * 1000));
        map.put("fence_id", String.valueOf(fence_id));
        map.put("fence_name", fence_name);
        map.put("lng", String.valueOf(lng));
        map.put("lat", String.valueOf(lat));
        map.put("coord_type", String.valueOf(coord_type));
        map.put("radius", String.valueOf(radius));
        map.put("pre_lng", String.valueOf(pre_lng));
        map.put("pre_lat", String.valueOf(pre_lat));
        map.put("pre_time", TimeUtils.millis2String(pre_time * 1000));
        map.put("pre_radius", String.valueOf(pre_radius));
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "saveFenceAlarmInfo.a", map, RequestTag.SAVE_FENCE_ALARM_INFO);
    }


    //-------------------------------------------------------------------

    /**
     * 提交服务评价
     * factoryTe   工厂处理效率满意度
     * factorySa  工厂的服务态度满意度
     * loadTs  装货处理流程满意度
     */
    public void commitServiceEvaluation(String phoneNumber, String orderNo, int factoryTe, int factorySa, int loadTs, String lng, String lat, String driverNum) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("orderCode", orderNo);
        map.put("factoryTe", String.valueOf(factoryTe));
        map.put("factorySa", String.valueOf(factorySa));
        map.put("loadTs", String.valueOf(loadTs));
        map.put("lng", lng);
        map.put("lat", lat);
        map.put("driverNum", driverNum);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "submissionEvaluation.a", map, RequestTag.COMMIT_SERVICE_EVALUATION);
    }

    /**
     * 待接收运单列表
     *
     * @param phoneNumber
     */
    public void canAcceptOrderList(String phoneNumber) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("status", "unabsorbed");
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loadAllOrder.a", map, RequestTag.CAN_ACCEPT_ORDER_LIST);
    }

    /**
     * 运送中运单列表
     *
     * @param phoneNumber
     */
    public void onTheRoadOrderList(String phoneNumber) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("status", "distribution");
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loadAllOrder.a", map, RequestTag.ON_THE_ROAD_ORDER_LIST);
    }

    /**
     * 已完成运单列表
     */
    public void completeOrderList(String phoneNumber) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("status", "complete");
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loadAllOrder.a", map, RequestTag.COMPLETE_ORDER_LIST);
    }

    /**
     * 获取负载单 详情
     */
    public void getOrderStatus(String phoneNumber, String orderCode) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("orderCode", orderCode);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loadDetailByTelAndCode.a", map, RequestTag.GET_ORDER_STATUS);
    }

    /**
     * 获取负载单状态码
     */
    public void getOrderCodeDetail(String phoneNumber, String orderCode) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("orderCode", orderCode);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loadDetailByTelAndCode.a", map, RequestTag.GET_ORDER_CODE_DETAIL);
    }

    /**
     * 司机接单
     * @param orderNo 订单号
     */
    public void driverAcceptOrder(String phoneNumber, String orderNo, String orderCodes, String lng, String lat, String driverNum) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("orderCode", orderNo);
        map.put("orderCodes", orderCodes);//交货单合集,以英文,隔开,弃用
        map.put("isAgree", "1");//接收或拒绝
        map.put("lng", lng);
        map.put("lat", lat);
        map.put("driverNum", driverNum);

        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "driverAcceptOrder.a", map, RequestTag.DRIVER_ACCEPT_ORDER);
    }


    //---------------------------------- 下面的url多加了 / ,现在把她去掉---------------------------------------------

    /**
     * 提交安全检查
     */
    public void commitSafeCheck(String phoneNumber, boolean isCheck1, boolean isCheck2, boolean isCheck3, boolean isCheck4, boolean isCheck5, boolean isCheck6, boolean isCheck7,
                                boolean isCheck8, boolean isCheck9, boolean isCheck10) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("isChecked1", String.valueOf(isCheck1));
        map.put("isChecked2", String.valueOf(isCheck2));
        map.put("isChecked3", String.valueOf(isCheck3));
        map.put("isChecked4", String.valueOf(isCheck4));
        map.put("isChecked5", String.valueOf(isCheck5));
        map.put("isChecked6", String.valueOf(isCheck6));
        map.put("isChecked7", String.valueOf(isCheck7));
        map.put("isChecked8", String.valueOf(isCheck8));
        map.put("isChecked9", String.valueOf(isCheck9));
        map.put("isChecked10", String.valueOf(isCheck10));
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "safeVeriSave.a", map, RequestTag.COMMIT_SAFE_CHECKED);
    }

    /**
     * 已废弃
     * 签到，不管是装货签到还是收货签到都是这个
     */
    public void sign(String phoneNumber, String orderCode, String number, String type) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("orderCode", orderCode);
        map.put("shpmNum", number);//交货单单号
        map.put("type", type);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "orderHandling.a", map, RequestTag.DRIVER_SIGN_ORDER);
    }

    /**
     * 签到，不管是装货签到还是收货签到都是这个
     */
    public void sign(String phoneNumber, String name, String orderNo, String shpmNum, String type, String lng, String lat, String driverNum) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("userName", name);
        map.put("orderCode", orderNo);
        map.put("shpmNum", shpmNum);//交货单单号
        map.put("type", type);
        map.put("lng", lng);
        map.put("lat", lat);
        map.put("driverNum", driverNum);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "orderHandling.a", map, RequestTag.DRIVER_SIGN_ORDER);
    }

    /**
     * 入厂
     */
    public void intoFactory(String phoneNumber, String orderNo, String lng, String lat, String driverNum) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("orderCode", orderNo);
        map.put("lng", lng);
        map.put("lat", lat);
        map.put("driverNum", driverNum);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "loadingPlant.a", map, RequestTag.INTO_FACTORY);
    }

    /**
     * 出厂
     */
    public void outFactory(String phoneNumber, String orderNo, String lng, String lat, String driverNum) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("orderCode", orderNo);
        map.put("lng", lng);
        map.put("lat", lat);
        map.put("driverNum", driverNum);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "exFactory.a", map, RequestTag.OUT_FACTORY);
    }

    /**
     * 收货入厂
     */
    public void intoEndFactory(String phoneNumber, String orderNo, String shpmNum, String flag, String lng, String lat, String driverNum) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("orderCode", orderNo);
        map.put("shpmNum", shpmNum);//交货单号
        map.put("flag", flag);
        map.put("lng", lng);
        map.put("lat", lat);
        map.put("driverNum", driverNum);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "receivingPlant.a", map, RequestTag.INTO_END_FACTORY);
    }

    /**
     * 收货出厂
     */
    public void outEndFactory(String phoneNumber, String orderNo, String shpmNum, String flag, String lng, String lat, String driverNum) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("orderCode", orderNo);
        map.put("shpmNum", shpmNum);//交货单号
        map.put("flag", flag);
        map.put("lng", lng);
        map.put("lat", lat);
        map.put("driverNum", driverNum);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "receivingDelivery.a", map, RequestTag.OUT_END_FACTORY);
    }

    /**
     * 回空确认
     */
    public void backEmptyConfirm(String phoneNumber, String name, String oldOrderCode, String oldShpmNum, String orderCode, String nums, String types) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("userName", name);
        map.put("oldOrderCode", oldOrderCode);
        map.put("oldShpmNum", oldShpmNum);
        map.put("orderCode", orderCode);
        map.put("nums", nums);//车牌号
        map.put("types", types);//车辆类型
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "emptySingleScheduling.a", map, RequestTag.BACK_EMPTY_CONFIRM);
    }

    /**
     * 获取首页数据
     */
    public void loadHomeOrder(String phoneNumber) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "homePageDisplay.a", map, RequestTag.LOAD_HOME_ORDER);
    }

    /**
     * 弃用
     * 是否有回瓶
     */
    public void getIsHaveEmpty(String phoneNumber, String orderCode) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phoneNumber);
        map.put("orderCode", orderCode);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "isEmptyOrders.a", map, RequestTag.IS_HAVA_EMPTY);
    }

    public void getHaveEmptyInfo(String orderCode, String tel, String loc) {
        HashMap<String, String> map = new HashMap<>();
        map.put("orderCode", orderCode);
        map.put("driverTel", tel);
        map.put("loc", loc);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "emptyOrderDetail.a", map, RequestTag.HAVE_EMPTY_INFO);
    }

    /**
     * 拒绝签到,弃用
     */
    public void rejectSign(String orderCode, String shpmNum) {
        HashMap<String, String> map = new HashMap<>();
        map.put("orderCode", orderCode);
        map.put("shpmNum", shpmNum);

        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "rejectSign.a", map, RequestTag.REJECT_SIGN);
    }

    //http://192.168.0.106:8085/itip/client/orderReturn.a?orderCode=11111

    /**
     * 常规-->装货工厂：签到+退回
     */
    public void orderReturn(String orderCode,String phone) {
        HashMap<String, String> map = new HashMap<>();
        map.put("orderCode", orderCode);
        map.put("driverTel", phone);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "orderReturn.a", map, RequestTag.ORDER_RETURN);
    }

    /**
     * 首页：是否已经提交安全检查
     */
    public void isSafeCheckCommit(String phone) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", phone);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "isSafeChecked.a", map, RequestTag.IS_SAFE_CHECK_COMMIT);
    }

    /**
     * 常规出厂后的回空 取消回空单
     */
    public void emptyCancel(String driverTel, String oldOrderCode, String oldShpmNum) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", driverTel);
        map.put("oldOrderCode", oldOrderCode);
        map.put("oldShpmNum", oldShpmNum);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "emptyCancel.a", map, RequestTag.EMPTY_CALCLE);
    }


    public void rejectReason(String type) {
        HashMap<String, String> map = new HashMap<>();
        map.put("type", type);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "rejectReason.a", map, RequestTag.REJECT_REASON);
    }

    public void getExceptionList(String driverTel) {
        HashMap<String, String> map = new HashMap<>();
        map.put("driverTel", driverTel);
        MainRequest.getInstance().makeStringPostRequest(NetUrl.zhuang + "abnormalList.a", map, RequestTag.EXCEPTION_LIST);
    }


}
